//
//  CTVHTTPMediaDownload.h
//  Channltv
//
//  Created by Bruno Keymolen on 29/08/07.
//  Copyright 2007 channl.tv. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <stdio.h>
#import "CTVClip.h"
#import "CTVMediaDownload.h"

//@class CTVMediaDownloadReply, CTVHTTPMediaDownload, CTVMediaDownloadUpdate;


enum{
	CTVDownloadError,
	CTVDownloadErrorAbort,
	CTVDownloadErrorFileSize,
	CTVDownloadErrorConnection
};

@interface CTVHTTPMediaDownload : CTVMediaDownload {
//	CTVMediaDownloadReply* m_mediaReply;
//	NSMutableArray* m_downloadUpdates; //CTVMediaDownloadUpdate*
	NSString* m_urlString;
	NSDate* m_startTime;
	long m_downloadFileLength;
	long m_downloadedLength; 
	NSURLConnection* m_connection;
	FILE* m_fileHandle;
	NSString* m_tempFile;
	NSTimer* m_timer;
	float m_intervalTimeLeftTimerInit;
	float m_intervalTimeLeftTimer;
//	CTVClip* m_clip;
	int m_httpStatusCode;
}

-(id)initWithURLString:(NSString*)urlString andClip:(CTVClip*)clip andMediaReply:(CTVMediaDownloadReply*)mediaReply;
-(int)startDownload;
-(int)stopDownload;
-(NSString*)urlString;
-(long)downloadFileLength;
-(long)downloadedLength;
//-(void)addDownloadUpdate:(CTVMediaDownloadUpdate*)update;
//-(void)removeDownloadUpdate:(CTVMediaDownloadUpdate*)update;
-(NSString*)cacheEntryNoExtension;
-(int)downloadRestTimeSec;
-(CTVClip*)clip;
-(int)httpStatusCode;

-(void)reportDownloadError:(int)err;
-(void)reportDownloadFinish;
-(void)reportDownloadPercent:(int)pc;
-(void)reportTimeLeft:(NSTimer*)timer;


@end
